package test.com.googlecode.likesql;

import junit.framework.TestCase;

import com.googlecode.likesql.LikeSql;
import com.googlecode.likesql.dml.DML;
import com.googlecode.likesql.expression.QuestExp;

/**
 * @author Johny Huang
 *
 */
public class DeleteSqlTester extends TestCase {

	public void testSimpleSql(){
		String eSql="DELETE FROM user WHERE id=1";
		String eTpl="DELETE FROM user WHERE id=?";
		
		LikeSql dSql=DML.deleteFrom("user").where(QuestExp.qt("id=?").set(1,1));
		
		assertEquals(eSql,dSql.toString());
		assertEquals(eTpl,dSql.toTemplate());
	}
	
	public void testMultiCriterias(){
		String eSql="DELETE FROM user WHERE id=1 and id=3 or gender='M'";
		String eTpl="DELETE FROM user WHERE id=? and id=? or gender=?";
		
		LikeSql dSql=DML.deleteFrom("user")
		                      .where(QuestExp.qt("id=? and id=? or gender=?")
		                    		  .set(1, 1)
		                    		  .set(2, 3)
		                    		  .set(3, 'M'));
		
		assertEquals(eSql,dSql.toString());
		assertEquals(eTpl,dSql.toTemplate());
	}
}
